#include "dialog_select_com.h"
#include "qextserialenumerator.h"
#include "ui_dialog_select_com.h"

#include <com_manager.h>


#ifdef Q_CC_MSVC
#pragma execution_character_set("utf-8")
#endif

DialogSelectCom::DialogSelectCom(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::DialogSelectCom)
{
    ui->setupUi(this);

    this->setWindowTitle(qApp->applicationName());

    QextSerialEnumerator* enumerator = new QextSerialEnumerator(this);
    enumerator->setUpNotifications();

    foreach(QextPortInfo info, QextSerialEnumerator::getPorts())
    {
        if (info.portName.isEmpty())
            continue;

      //  if (info.portName.friendName.contains("CH34" ))
        {
            ui->comboBox->addItem(  info.portName + "  " +  info.friendName  );
        }
    }
}

DialogSelectCom::~DialogSelectCom()
{
    delete ui;
}

void DialogSelectCom::on_buttonBox_accepted()
{
    QString com_name = ui->comboBox->currentText();
    int pos = com_name.indexOf(" ");

    com_manager::instance()-> curComName = com_name.mid( 0, pos);
   // com_manager::instance()->curComName.append(com_name);
}

